﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using ESRI.ArcGIS.Geometry;
using DGIS.Service.IService.ICoordService;

namespace DGIS.Service.Service.CoordService
{
    public class SpatialReferenceService : ISpatialReferenceService
    {
        public ISpatialReference CreateSpatialReference(string prj)
        {
            ISpatialReferenceFactory spatialReferenceFactory = new SpatialReferenceEnvironmentClass();
            ISpatialReference spatialReference = spatialReferenceFactory.CreateESRISpatialReferenceFromPRJ(prj);

            return spatialReference;
        }

        public ISpatialReference CreateSpatialReference(esriSRProjCSType type)
        {
            ISpatialReferenceFactory spatialReferenceFactory = new SpatialReferenceEnvironmentClass();
            ISpatialReference spatialReference = spatialReferenceFactory.CreateProjectedCoordinateSystem((int)type);

            return spatialReference;
        }

        public ISpatialReference CreateSpatialReference(esriSRGeoCSType type)
        {
            ISpatialReferenceFactory spatialReferenceFactory = new SpatialReferenceEnvironmentClass();
            ISpatialReference spatialReference = spatialReferenceFactory.CreateGeographicCoordinateSystem((int)type);

            return spatialReference;
        }

        public ISpatialReference CreateSpatialReferenceFromPrjFile(string prjFilePath)
        {
            ISpatialReferenceFactory spatialReferenceFactory = new SpatialReferenceEnvironmentClass();
            ISpatialReference spatialReference = spatialReferenceFactory.CreateESRISpatialReferenceFromPRJFile(prjFilePath);

            return spatialReference;
        }
    }
}
